home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / awt / GraphicsConfiguration.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  7.3 KB  |  174 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)GraphicsConfiguration.java    1.17 98/06/29
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt;
  16.  
  17. import java.awt.geom.AffineTransform;
  18. import java.awt.image.BufferedImage;
  19. import java.awt.image.ColorModel;
  20.  
  21. /**
  22.  * The <code>GraphicsConfiguration</code> class describes the
  23.  * characteristics of a graphics destination such as a printer or monitor.
  24.  * There can be many <code>GraphicsConfiguration</code> objects associated
  25.  * with a single graphics device.  For example, on X11 windowing systems,
  26.  * each visual is a different <code>GraphicsConfiguration</code>.  On PCs
  27.  * and Macintoshes, the different screen resolution/color resolution
  28.  * combinations would be different <code>GraphicsConfiguration</code>
  29.  * objects.
  30.  * @see GraphicsEnvironment
  31.  * @see GraphicsDevice
  32.  */
  33. /*
  34.  * REMIND:  What to do about capabilities?
  35.  * The
  36.  * capabilities of the device can be determined by enumerating the possible
  37.  * capabilities and checking if the GraphicsConfiguration
  38.  * implements the interface for that capability.
  39.  *
  40.  * @version  10 Feb 1997
  41.  */
  42.  
  43.  
  44. public abstract class GraphicsConfiguration {
  45.     /**
  46.      * This is an abstract class that cannot be instantiated directly.
  47.      * Instances must be obtained from a suitable factory or query method.
  48.      *
  49.      * @see GraphicsDevice#getConfigurations
  50.      * @see GraphicsDevice#getDefaultConfiguration
  51.      * @see GraphicsDevice#getBestConfiguration
  52.      * @see Graphics2D#getDeviceConfiguration
  53.      */
  54.     protected GraphicsConfiguration() {
  55.     }
  56.  
  57.     /**
  58.      * Returns the {@link GraphicsDevice} associated with this
  59.      * <code>GraphicsConfiguration</code>.
  60.      * @return a <code>GraphicsDevice</code> object that is 
  61.      * associated with this <code>GraphicsConfiguration</code>.
  62.      */
  63.     public abstract GraphicsDevice getDevice();
  64.  
  65.     /**
  66.      * Returns a {@link BufferedImage} with a data layout and color model
  67.      * compatible with this <code>GraphicsConfiguration</code>.  This
  68.      * method has nothing to do with memory-mapping
  69.      * a device.  The returned <code>BufferedImage</code> has
  70.      * a layout and color model that is closest to this native device
  71.      * configuration and can therefore be optimally blitted to this
  72.      * device.
  73.      * @param width the width of the returned <code>BufferedImage</code>
  74.      * @param height the height of the returned <code>BufferedImage</code>
  75.      * @return a <code>BufferedImage</code> whose data layout and color
  76.      * model is compatible with this <code>GraphicsConfiguration</code>.
  77.      */
  78.     public abstract BufferedImage createCompatibleImage(int width, int height);
  79.  
  80.     /**
  81.      * Returns a <code>BufferedImage</code> that supports the specified
  82.      * transparency and has a data layout and color model
  83.      * compatible with this <code>GraphicsConfiguration</code>.  This
  84.      * method has nothing to do with memory-mapping
  85.      * a device. The returned <code>BufferedImage</code> has a layout and
  86.      * color model that can be optimally blitted to a device
  87.      * with this <code>GraphicsConfiguration</code>.
  88.      * @param width the width of the returned <code>BufferedImage</code>
  89.      * @param height the height of the returned <code>BufferedImage</code>
  90.      * @param transparency the specified transparency mode
  91.      * @return a <code>BufferedImage</code> whose data layout and color  
  92.      * model is compatible with this <code>GraphicsConfiguration</code>
  93.      * and also supports the specified transparency.
  94.      * @see Transparency#OPAQUE
  95.      * @see Transparency#BITMASK
  96.      * @see Transparency#TRANSLUCENT
  97.      */
  98.     public abstract BufferedImage createCompatibleImage(int width, int height,
  99.                                                         int transparency);
  100.  
  101.     /**
  102.      * Returns the {@link ColorModel} associated with this 
  103.      * <code>GraphicsConfiguration</code>.
  104.      * @return a <code>ColorModel</code> object that is associated with
  105.      * this <code>GraphicsConfiguration</code>.
  106.      */
  107.     public abstract ColorModel getColorModel();
  108.  
  109.     /**
  110.      * Returns the <code>ColorModel</code> associated with this
  111.      * <code>GraphicsConfiguration</code> that supports the specified
  112.      * transparency.
  113.      * @param transparency the specified transparency mode
  114.      * @return a <code>ColorModel</code> object that is associated with
  115.      * this <code>GraphicsConfiguration</code> and supports the 
  116.      * specified transparency.
  117.      */
  118.     public abstract ColorModel getColorModel(int transparency);
  119.  
  120.     /**
  121.      * Returns the default {@link AffineTransform} for this 
  122.      * <code>GraphicsConfiguration</code>. This
  123.      * <code>AffineTransform</code> is typically the Identity transform
  124.      * for most normal screens.  The default <code>AffineTransform</code>
  125.      * maps coordinates onto the device such that 72 user space
  126.      * coordinate units measure approximately 1 inch in device
  127.      * space.  The normalizing transform can be used to make
  128.      * this mapping more exact.  Coordinates in the coordinate space
  129.      * defined by the default <code>AffineTransform</code> for screen and
  130.      * printer devices have the origin in the upper left-hand corner of
  131.      * the target region of the device, with X coordinates
  132.      * increasing to the right and Y coordinates increasing downwards.
  133.      * For image buffers not associated with a device, such as those not
  134.      * created by <code>createCompatibleImage</code>,
  135.      * this <code>AffineTransform</code> is the Identity transform.
  136.      * @return the default <code>AffineTransform</code> for this
  137.      * <code>GraphicsConfiguration</code>.
  138.      */
  139.     public abstract AffineTransform getDefaultTransform();
  140.  
  141.     /**
  142.      *
  143.      * Returns a <code>AffineTransform</code> that can be concatenated
  144.      * with the default <code>AffineTransform</code>
  145.      * of a <code>GraphicsConfiguration</code> so that 72 units in user
  146.      * space equals 1 inch in device space.  
  147.      * <p>
  148.      * For a particular {@link Graphics2D}, g, one
  149.      * can reset the transformation to create
  150.      * such a mapping by using the following pseudocode:
  151.      * <pre>
  152.      *      GraphicsConfiguration gc = g.getGraphicsConfiguration();
  153.      *
  154.      *      g.setTransform(gc.getDefaultTransform());
  155.      *      g.transform(gc.getNormalizingTransform());
  156.      * </pre>
  157.      * Note that sometimes this <code>AffineTransform</code> is identity,
  158.      * such as for printers or metafile output, and that this 
  159.      * <code>AffineTransform</code> is only as accurate as the information
  160.      * supplied by the underlying system.  For image buffers not
  161.      * associated with a device, such as those not created by
  162.      * <code>createCompatibleImage</code>, this
  163.      * <code>AffineTransform</code> is the Identity transform
  164.      * since there is no valid distance measurement.
  165.      * @return an <code>AffineTransform</code> to concatenate to the
  166.      * default <code>AffineTransform</code> so that 72 units in user
  167.      * space is mapped to 1 inch in device space.
  168.      */
  169.     public abstract AffineTransform getNormalizingTransform();
  170.  
  171. }
  172.  
  173.  
  174.